import numpy as np

# 相机位置和朝向
camera_position = np.array([0, 0, 0])
camera_orientation = np.array([[1, 0, 0],
                                [0, 1, 0],
                                [0, 0, 1]])

# 计算相机到世界坐标系的变换矩阵
camera_transform_matrix = np.linalg.inv(np.hstack((camera_orientation, camera_position.reshape(-1, 1))))
camera_transform_matrix = np.vstack((camera_transform_matrix, np.array([0, 0, 0, 1])))

# 将模型顶点坐标从世界坐标系转换到相机坐标系
def to_camera_coordinate(model_vertices):
    return np.dot(model_vertices, camera_transform_matrix[:3, :3].T) + camera_transform_matrix[:3, 3]
